home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Sample Code / Games / MoofWars / MoofWars Encoder 8⁄15⁄96 / •Headers / main.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-19  |  5.3 KB  |  172 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************
  2. #
  3. #    Main.h
  4. #    
  5. #    An extremely basic encoder utility to assist in building all of the various
  6. #   "compiled" resources used by MoofWars.  Many of the encoder utilities are actually
  7. #   handled by things in the standard TGraphic class, so the main reason for pre-encoding
  8. #   the graphics is to improve the time to load the graphics in the game.
  9. #   
  10. #
  11. #    Author: Timothy Carroll
  12. #    Apple Developer Technical Support
  13. #    timc@apple.com
  14. #
  15. #    Modification History: 
  16. #
  17. #    8/15/96        TMC     Initial Release
  18. #
  19. #    Copyright © 1996 Apple Computer, Inc., All Rights Reserved
  20. #
  21. #
  22. #    You may incorporate this sample code into your applications without
  23. #    restriction, though the sample code has been provided "AS IS" and the
  24. #    responsibility for its operation is 100% yours.  However, what you are
  25. #    not permitted to do is to redistribute the source as "DSC Sample Code"
  26. #    after having made changes. If you're going to re-distribute the source,
  27. #    we require that you make it clear in the source that the code was
  28. #    descended from Apple Sample Code, but that you've made changes.
  29. #
  30. *************************************************************************************/
  31.  
  32. #ifndef _MOOFENCODE_
  33. #define _MOOFENCODE_
  34.  
  35. #pragma once
  36.  
  37. #include <MacHeadersPPC++>
  38. #include <Quickdraw.h>
  39. #include <QDOffscreen.h>
  40. #include <Palettes.h>
  41. #include <DrawSprocket.h>
  42.  
  43.  
  44. /*************************************************************************************
  45. #
  46. #    CONDITIONALS
  47. #
  48. #   Like MoofWars, we'll define a few conditional macros that assist in configuring how
  49. #   the application actually works.  For the moment, we'll just have one, the debugging macro.
  50. #
  51. #
  52. #    qDebugging  -- Whether or not additional debugging code should be inserted.  With this
  53. #   turned on, most errors will DebugStr almost immediately and return errors as the error
  54. #   propagates up the calling chain.  This is slower, but if you've found a weird bug,
  55. #   this is the fastest way to replicate it.
  56. #
  57. *************************************************************************************/
  58.  
  59. #define qDebugging 1
  60.  
  61.  
  62. /*********************************************************************************
  63. #    ERROR HANDLING MACROS
  64. #
  65. #    These macros can be used to implement nice error handling within a function.
  66. #    Essentially, all errors jump to an error handler at the end of the function, which
  67. #    should cleanup  any leftovers and return the appropriate error result.
  68. #
  69. #    Note that the error handlers take a message string.  This should be a good
  70. #    indication of the actual error, and it will appear when debugging is turned on.
  71. #
  72. #    Note that any additional sanity checking code can be added to any function by using
  73. #
  74.     
  75.     #if qDebugging
  76.           // do additional sanity checking here.
  77.     #endif
  78. #
  79. #    For example, this could be used to check the internal validity of an object before
  80. #    taking an action.
  81. #    
  82. *********************************************************************************/
  83. #ifndef qDebugging
  84.     #define qDebugging 0
  85. #endif
  86.  
  87. #if qDebugging
  88.     #define SIGNAL_ERROR(msg)        {DebugStr(msg); goto error;}
  89. #else
  90.     #define SIGNAL_ERROR(msg)        {goto error;}
  91. #endif
  92.  
  93. #define FAIL_NIL(y,msg)            if (y == NULL) SIGNAL_ERROR(msg)
  94. #define FAIL_OSERR(y,msg)        if (y != noErr) SIGNAL_ERROR(msg)
  95. #define FAIL_FALSE(y,msg)        if (!y) SIGNAL_ERROR(msg)
  96.     
  97.  
  98. /*********************************************************************************
  99.     OTHER NECESSARY HEADERS    
  100. *********************************************************************************/
  101. #include "Scaling.h"
  102. #include "TGraphicCollection.h"
  103.  
  104.  
  105. /*********************************************************************************
  106.     CONSTANTS    
  107. *********************************************************************************/
  108.  
  109.  
  110. // A few standard colors -- probably should use palette calls instead!
  111. const RGBColor kWhite = {0xFFFF, 0xFFFF, 0xFFFF};
  112. const RGBColor kBlack = {0x0000, 0x0000, 0x0000};
  113. const RGBColor kDarkBlue = {0x0000,0x0000,0x7000};
  114. const RGBColor kLtGrey = {0xC000,0xC000,0xC000};
  115. const RGBColor kMediumGrey = {0x7FFF,0x7FFF,0x7FFF};
  116.  
  117. // The ResID of the application's color table.  All of my custom graphics routines use
  118. // an 8-bit color table and the sprite is encoded to use these colors.  The actual variable
  119. // to hold the color table is declared below.
  120.  
  121. enum {
  122.     kAppColorTableResID = 128
  123. };
  124.  
  125. // Various constants used to load the background tile and sprite graphics.
  126.  
  127. enum {
  128.     kGridResourceID = 500
  129. };
  130.  
  131. enum {
  132.     kPreferredDepth = 8
  133. };
  134.  
  135. // We'll use these contants to tailor the Application's behavior.
  136. enum {
  137.     kEventInterval = 3,
  138.     kNumberOfMasters = 10,
  139.     kSleepTime = 0
  140. };
  141.  
  142. // Constants for all the menu functions
  143. enum
  144. {
  145.     rMenuBar = 128,
  146.     mAppleMenu = 128,
  147.         iAboutApp = 1,
  148.     mFileMenu = 129,
  149.         iEncodeIcons = 1,
  150.         iEncodePICTs = 2,
  151.         iTriplePICTs = 4,
  152.         iEncodeTiles = 5,
  153.         iQuit = 7
  154. };
  155.  
  156. /*********************************************************************************
  157.     Globals    
  158. *********************************************************************************/
  159.  
  160. // The main color table described above
  161. extern CTabHandle            gAppColorTable;
  162.  
  163.  
  164. /*********************************************************************************
  165.     Functions    
  166. *********************************************************************************/
  167.  
  168. OSStatus CopyResource (SInt16 inRes, SInt16 outRes, OSType theType, SInt16 theID);
  169.  
  170. #endif /* _MOOFENCODE_ */
  171.  
  172.